package com.esyoga.yoyoga.handler;

import com.esyoga.yoyoga.pojo.TStudent;
import com.esyoga.yoyoga.pojo.TTrainer;
import com.esyoga.yoyoga.service.AddressInfoService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
@RequestMapping("/address")
public class AddressInfoHandler {
    @Resource
    AddressInfoService addressInfoService;

    @RequestMapping("/getStudentsAddressMap")
    @ResponseBody
    public List<TStudent> getStudentsAddressMap(HttpServletRequest request,double distance){
        TTrainer trainer = (TTrainer) request.getSession().getAttribute("tTrainer");
        List<TStudent> studentsInfo = addressInfoService.getStudentAddressMap(trainer,distance);
        return studentsInfo;
    }

    @RequestMapping("/getTrainersAddressMap")
    @ResponseBody
    public List<TTrainer> getTrainersAddressMap(HttpServletRequest request,double distance){
        TStudent student = (TStudent) request.getSession().getAttribute("tStudent");
        List<TTrainer> trainersInfo = addressInfoService.getTrainersAddressMap(student,distance);
        return trainersInfo;
    }
}
